package com.cloud.dao.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Component;

import com.cloud.core.BaseDao;
import com.cloud.dao.AppointmentBean;

/**
 * 1Cloud1
 * @author Administrator
 * @since 2016-1-19
 * @version 1.0 
 */
@Component("AppointmentDao")
public class AppointmentDao extends BaseDao {
	
	public List<AppointmentBean> getClinicList(AppointmentBean bean){
		SqlSession session = super.getInstance(true);
		List<AppointmentBean> beanList = null;
		try {
			beanList = session.selectList("appointment.cliniclist", bean);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			session.close();
		}
		return beanList;
	}
	
	public String addClinic(AppointmentBean bean){
		SqlSession session = super.getInstance(true);
		session.insert("appointment.insertclinic", bean);
		session.close();
		return bean.getId();
	}
	
	public void updateClinic(AppointmentBean bean){
		SqlSession session = super.getInstance(true);
		session.update("appointment.updateclinic", bean);
		session.close();
	}
	
	public void deleteClinic(AppointmentBean bean){
		SqlSession session = super.getInstance(true);
		session.delete("appointment.deleteclinic", bean);
		session.close();
	}
	
	public List<AppointmentBean> getAppointmentList(AppointmentBean bean){
		SqlSession session = super.getInstance(true);
		List<AppointmentBean> beanList = null;
		try {
			beanList = session.selectList("appointment.appointmentlist", bean);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			session.close();
		}
		return beanList;
	}
	
	public List<AppointmentBean> getPatientAppointmentList(AppointmentBean bean){
		SqlSession session = super.getInstance(true);
		List<AppointmentBean> beanList = null;
		try {
			beanList = session.selectList("appointment.appointmentlist", bean);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			session.close();
		}
		return beanList;
	}
	
	public String addAppointment(AppointmentBean bean){
		SqlSession session = super.getInstance(true);
		session.insert("appointment.insertappointment", bean);
		session.close();
		return bean.getId();
	}
	
	public void updateAppointment(AppointmentBean bean){
		SqlSession session = super.getInstance(true);
		session.update("appointment.updateappointment", bean);
		session.close();
	}
	
	public void deleteAppointment(AppointmentBean bean){
		SqlSession session = super.getInstance(true);
		session.delete("appointment.deleteappointment", bean);
		session.close();
	}
}
